local cesuan = fk.CreateSkill{
    name = "XD__cesuan",
    tags = {Skill.Compulsory}
}
Fk:loadTranslationTable{
    ["XD__cesuan"] = "策算",
    [":XD__cesuan"] = "锁定技，当你使用普通锦囊牌后，你观看牌堆顶的三张牌，然后获得其中一张牌，将其余的牌以任意顺序置于牌堆顶。",
    ["#XD__cesuan"] = "策算：获得其中一张牌，将其余的牌以任意顺序置于牌堆顶",
    ["prey"] = "获得",
}

cesuan:addEffect(fk.CardUseFinished, {
    anim_type = "drawcard",
    can_trigger = function (self, event, target, player, data)
        return target == player and player:hasSkill(cesuan.name) and data.card:isCommonTrick()
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local ret = room:askToArrangeCards(player,{
            skill_name = cesuan.name,
            card_map = { room:getNCards(3), "Top", "prey" },
            prompt = "#XD__cesuan",
            free_arrange = true,
            max_limit = { 3, 1 },
            min_limit = { 2, 1 }
        })
        local top, prey = ret[1], ret[2]
        for i = #top, 1, -1 do
            table.removeOne(room.draw_pile, top[i])
            table.insert(room.draw_pile, 1, top[i])
        end
        room:obtainCard(player, prey, true, fk.ReasonJustMove, player, cesuan.name)
    end,
})

return cesuan